package com.nhom4.ADP;

import java.util.Scanner;

public class Fraction {

	Scanner kb = new Scanner(System.in);
	protected int numirator, denominator;

	public Fraction() {
		numirator = 0;
		denominator = 1;
	}

	public Fraction(int a, int b) {
		numirator = a;
		denominator = b;
	}

	public void input() {
		System.out.println("Enter numirator:");
		numirator = kb.nextInt();
		System.out.println("Enter denominator:");
		denominator = kb.nextInt();

	}

	public String output() {
		if (denominator == 0)
			return null;
		else if (numirator == 0)
			return "0";
		String s = numirator + "/" + denominator;
		return s;
	}

	public void plus(Fraction f1, Fraction f2) {
		this.numirator = f1.numirator * f2.denominator + f1.denominator
				* f2.numirator;
		this.denominator = f1.denominator * f2.denominator;
	}

	public void subtract(Fraction f1, Fraction f2) {
		this.numirator = f1.numirator * f2.denominator - f2.numirator
				* f1.denominator;
		this.denominator = f1.denominator * f2.denominator;
	}

	public void multiply(Fraction f1, Fraction f2) {
		this.numirator = f1.numirator * f2.numirator;
		this.denominator = f1.denominator * f2.denominator;
	}

	public void divided(Fraction f1, Fraction f2) {
		this.numirator = f1.numirator * f2.denominator;
		this.denominator = f1.denominator * f2.numirator;

	}

	public void sum(Fraction f1) {
		this.numirator = this.numirator * f1.denominator + f1.numirator
				* this.denominator;
		this.denominator = this.denominator * f1.denominator;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
